<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Validator;
class Validate extends Model
{
    protected $table = 'validate';
    public $timestamps = false;
    //
    //验证绑定手机号
    public function checkValidate($data){
        $rules = array(
            'phone'=>'required|regex:/^1[34578][0-9]{9}$/',
            'code'=>'required|size:6'
        );
        $message = array(
            "required"             => ":attribute 不能为空",
            "regex"             => "手机号不合法",
            "size"             => "验证码不正确"
        );

        $attributes = array(
            "phone" => '手机号',
            "code" => '验证码',
        );

        $validate = Validator::make($data,$rules,$message,$attributes);
        return $validate;
    }
}
